<template>
  <div>
    <h3>axios post</h3>
    <test-post></test-post>
  </div>
</template>

<script>
import axios from "axios";
import TestPost from "@/components/TestPost";
export default {
  components: {
    TestPost,
  },
  mounted() {
    //axios常见配置项
    axios({
      method: "get",
      url: "/search_info_item",
      baseURL: "http://localhost:8000",
      headers: "",
      //在向服务器提交前，截住数据进行修改
      transformRequest: [],
      // 在传递给then  / catch前 修改响应数据
      transformResponse: [
        function (data) {
          console.log(data);
          data = JSON.parse(data);
          return data;
        },
      ],
      // 与url一起发送的参数
      params: {
        stu_id: "001",
      },
      // 作为请求体被发送的数据
      data: {},
      timeout: 1000,
    }).then((res) => {
      console.log(res.data);
    }).catch((err) => {
      console.log(err);
    })
  }
}
</script>

<style lang="scss" scoped>

</style>